<%@ page contentType="text/html; charset=utf-8" %>
<%@ page language="java" pageEncoding="utf-8"%>

<%@ include file="header.jsp" %>
<body>

<div id="new_message" data-role="page" data-rockncoder-jspage="manageBarChart">  
 	
 	<header data-role="header" data-position="fixed">
    	<a data-rel="back" data-icon="back" data-transition="fade">Powrót</a>
      	<h1>Nowa wiadomość</h1>
    </header>
    
    <section data-role="content">
    			<!-- ERROR MESSAGE -->
			<%@ taglib prefix="s" uri="/struts-tags"%>
			<s:if test="hasActionErrors()">
				<a id="linkErrorRejestracja" href="#errorRejestracja"
					data-rel="popup" data-position-to="window" data-transition="flip"
					data-theme="a" data-overlay-theme="a"></a>
				<div data-role="popup" id="errorRejestracja">
					<div class="errorPopup">
						<h4>
							<s:actionerror />

						</h4>
						<a data-role="button" data-rel="back" data-icon="arrow-l">Powrót</a>
					</div>
				</div>
				<script>
					$("#linkErrorRejestracja").click();
				</script>
			</s:if>
			
		<form method="post" action="message!send.action" data-ajax="false">
			<div data-role="fieldcontain">
				<label for="messageRecivers" class="select">Wyślij do:</label>
				<select name="messageRecivers" id="messageRecivers" data-mini="true">
				</select>
			</div>
			
			<div data-role="fieldcontain">
				<label for="messageTopic">Temat:</label>
				<input type="text" id="messageTopic" name="messageTopic"></input>
			</div>
			
			<div data-role="fieldcontain">
				<label for="messageContent">Treść:</label>
				<textarea name="messageContent" id="messageContent" maxlength="700"></textarea>
			</div>
			
			<input type="submit" value="Wyślij"/>
		</form>
		
		 <script>
			function startInfo(){
				 $.ajax(
						   {
						      type: "POST",
						      url: "message!getNameOfAdministrator.action",
						      success: function( response ) 
						      { 
						    	  if(response != "null"){
							    	  $('#messageRecivers').append('<option value="admin" selected="selected">' + response + '</option>');
							    	  $('#messageRecivers').selectmenu('refresh');
						    	  }
						      }
						   } );
				 
				 $.ajax(
						   {
						      type: "POST",
						      url: "message!getNameOfMyInstructor.action",
						      success: function( response ) 
						      { 
						    	  if(response != "null"){
							    	  $('#messageRecivers').append('<option value="instruktor" selected="selected">' + response + '</option>');
							    	  $('#messageRecivers').selectmenu('refresh');
						    	  }
						      }
						   } );
			 
			 }
		 
		 onload=startInfo();	
		</script>
		
    </section>
    
    <div data-role="footer">
		<h4>E-PRAWO JAZDY</h4>
	</div>
</div>

</body>
</html>